package igs.android.muzibox;

import java.util.concurrent.TimeUnit;

import android.os.Bundle;
import android.app.Activity;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

public class MainActivity extends Activity {

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		LinearLayout login_view = (LinearLayout) findViewById(R.id.login_view);
		Animation fadein = AnimationUtils.loadAnimation(this, R.anim.fade_in);
		fadein.setDuration(2000);
		login_view.startAnimation(fadein);
		
		Button button_reg = (Button) findViewById(R.id.myButton_reg);
		button_reg.setOnClickListener(new Button.OnClickListener(){
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				nextview();
			}			
		});


	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.activity_main, menu);
		return true;
	}

	public void nextview() {
		
		RelativeLayout login_layout = (RelativeLayout) findViewById(R.id.login_layout);
		Animation fadein = AnimationUtils.loadAnimation(this, R.anim.fade_in);
		login_layout.startAnimation(fadein);
		Log.d("Tag1","xxx_1");
		MyThread myThread = new MyThread();
		myThread.setRunning();

		while(myThread.running);
		Log.d("Tag1","xxx_2");
		Intent intent = new Intent();
		intent.setClass(this, RegActivity.class);
		startActivity(intent);
		Log.d("Tag1","xxx_3");		
	}

	
	public class MyThread extends Thread{
		private boolean running = false;
		public void setRunning()
		{
			running = true;
			start();
		}
		@Override
		public void run(){
			try {
				Log.d("Tag1","xxx_4");				
				Thread.sleep(3000);
				Log.d("Tag1","xxx_5");				
				running = false;
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
	
	}

	
	

}
